package com.cbb.lease.controller;

import com.cbb.lease.pojo.entity.TbCar;
import com.cbb.lease.pojo.vo.Catvo;
import com.cbb.lease.service.TbCarService;
import com.gsj.common.pojo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (TbCar)表控制层
 *
 * @author makejava
 * @since 2021-07-23 15:23:14
 */
@RestController
@Api(value ="lease/tbCar",description = "返回汽车的信息")
@RequestMapping("lease/tbCar")
public class TbCarController {
    /**
     * 服务对象
     */
    @Resource
    private TbCarService tbCarService;

    /**
     * 通过主键查询单条数据
     *
     * @return 单条数据
     */
    @ApiOperation(value = "getAllCat",httpMethod = "Post" ,notes = "必须传递 currentPage和 pageSize Catvo对象可以不传参")
    @PostMapping("getAllCat/{currentPage}/{pageSize}")
    public R getAlRlCat(@PathVariable("currentPage")Integer currentPage,
                        @PathVariable("pageSize")Integer pageSize,
                        @RequestBody Catvo catvo
    ) {
        return tbCarService.getAllCat(currentPage,pageSize,catvo);
    }

    @ApiOperation(value = "delCatById",httpMethod = "Delete",notes = "根据汽车Id删除汽车信息")
    @DeleteMapping("delCatById")
    public R delCatById(
            @ApiParam(value = "这是一个汽车ID",required = true)
            Integer  id
            ){
        return tbCarService.deleteById(id);
    }

    @ApiOperation(value = "updateCar",httpMethod = "put")
    @PutMapping("updateCar")
    public R updateCar(@ApiParam(value = "汽车实体类")
                       @RequestBody TbCar car){
        return tbCarService.updateCar(car);
    }

    @ApiOperation(value = "addCar",httpMethod = "post")
    @PostMapping("addCar")
    public R addCar(@ApiParam(value = "汽车实体类")
                     @RequestBody TbCar car
    ){
        return tbCarService.addCar(car);
    }

    @ApiOperation(value = "跟据id修改汽车状态",httpMethod = "post")
    @PostMapping("updateState2/{id}")
    public R updateCarState2(@PathVariable Integer id){
           return   tbCarService.updateCarState(id);
    }

    @ApiOperation(value = "跟据id修改汽车状态",httpMethod = "post")
    @PostMapping("updateState1/{id}")
    public R updateCarState1(@PathVariable Integer id){
        return   tbCarService.updateCarState1(id);
    }








}
